/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.aber.compsci.se3920.groupA.Tests;

import java.util.ArrayList;
import java.util.Calendar;
import uk.ac.aber.compsci.se3920.groupA.Tests.MockTypes.ActiveParticipantPreference;
import uk.ac.aber.compsci.se3920.groupA.Tests.MockTypes.Equipment;
import uk.ac.aber.compsci.se3920.groupA.Tests.MockTypes.ExclusionRange;
import uk.ac.aber.compsci.se3920.groupA.Tests.MockTypes.MeetingCandidate;
import uk.ac.aber.compsci.se3920.groupA.Tests.MockTypes.Room;

/**
 *
 * @author rob
 */
public class Setup {
       
    private Config config;
    private int defaultHourDayStart = 7;
    private int defaultHourDayEnd = 20;
    private int defaultExclusionStart = 12;
    private int defaultExclusionEnd = 14;
    private int exStart, exEnd;
    
    public Setup(Config config){
        this.config = config;
        exStart = this.defaultExclusionStart;
        exEnd = this.defaultExclusionEnd;
    }

    public void populateRooms(ArrayList<Room> roomList) {
        Room temp = new Room("c56", Config.DEPT_COMPSCI, 40);
        temp.addEquipment(new Equipment("prj1", Config.DEPT_COMPSCI, Config.EQUIP_PROJECTOR));
        temp.addEquipment(new Equipment("comp1", Config.DEPT_COMPSCI, Config.EQUIP_COMPUTER));
        temp.addEquipment(new Equipment("wifi1", Config.DEPT_COMPSCI, Config.EQUIP_WIRELESS));
        roomList.add(temp);

        temp = new Room("Physics A", Config.DEPT_PHYSICS, 45);
        temp.addEquipment(new Equipment("prj2", Config.DEPT_PHYSICS, Config.EQUIP_PROJECTOR));
        temp.addEquipment(new Equipment("comp2", Config.DEPT_PHYSICS, Config.EQUIP_COMPUTER));
        temp.addEquipment(new Equipment("wifi2", Config.DEPT_PHYSICS, Config.EQUIP_WIRELESS));
        roomList.add(temp);

        temp = new Room("320", Config.DEPT_PHYSICS, 15);
        temp.addEquipment(new Equipment("prj3", Config.DEPT_PHYSICS, Config.EQUIP_PROJECTOR));
        temp.addEquipment(new Equipment("comp3", Config.DEPT_PHYSICS, Config.EQUIP_COMPUTER));
        roomList.add(temp);

        temp = new Room("512", Config.DEPT_ENGLISH, 60);
        temp.addEquipment(new Equipment("prj4", Config.DEPT_ENGLISH, Config.EQUIP_PROJECTOR));
        temp.addEquipment(new Equipment("dic1", Config.DEPT_ENGLISH, Config.EQUIP_DICTIONARY));
        roomList.add(temp);
    }
    
    public void createMeetingCandidates(Calendar time, ArrayList<MeetingCandidate> mcList, ArrayList<ActiveParticipantPreference> appList){
    
        time.set(Calendar.MINUTE, 0);
        time.set(Calendar.SECOND, 0);

        //Create 2 days of candidates
        //On each day, our active participant prefers to work from 14:00-17:00
        int day = time.get(Calendar.DAY_OF_MONTH);
        for (int x = day; x <= day + config.getNumDaysToGenerate(); x++) {
            time.set(Calendar.DAY_OF_MONTH, x);
            ActiveParticipantPreference app = new ActiveParticipantPreference();
            app.setStart((Calendar) time.clone());
            app.getStart().set(Calendar.HOUR_OF_DAY, 14);
            app.setEnd((Calendar) app.getStart().clone());
            app.getEnd().set(Calendar.HOUR_OF_DAY, 17);
            appList.add(app);

            for (int i = defaultHourDayStart; i < defaultHourDayEnd; i++) {
                time.set(Calendar.HOUR_OF_DAY, i);
                time.set(Calendar.MINUTE, 0);
                time.set(Calendar.SECOND, 0);

                for (int j = 20; j <= 60; j += 20) {
                    MeetingCandidate tempMC = new MeetingCandidate();
                    tempMC.setStart((Calendar) time.clone());
                    time.set(Calendar.MINUTE, j);
                    tempMC.setEnd((Calendar) time.clone());
                    mcList.add(tempMC);
                }
            }
        }
    }
    
    public void createExclusionSets(Calendar time, ArrayList<ExclusionRange> exList){
        time.set(Calendar.MINUTE, 0);

        //Create an exclusion set that runs from 12 - 2
        for (int i = exStart; i < exEnd; i++) {
            ExclusionRange tempEX = new ExclusionRange();
            time.set(Calendar.HOUR_OF_DAY, i);
            tempEX.setStart((Calendar) time.clone());
            time.set(Calendar.HOUR_OF_DAY, i + 1);
            tempEX.setEnd((Calendar) time.clone());
            exList.add(tempEX);
        }
    }
    
    
    public void setExclusionStart(int start){
        this.exStart = start;
    }
    
    public void setExclusionEnd(int end){
        this.exEnd = end;
    }
}
